#!/usr/bin/env python

# encoding: utf-8

'''
 * Create File phone
 * Created by leixu on 2017/12/15
 * IDE PyCharm
'''
import requests
from luobocrawler.third_imp.phone import phone_setting


def get_random_phone():
    r = requests.get(f'http://{phone_setting.host}:{phone_setting.port}/api/telephone/get_random_phone')
    return r.json()["body"]


def get_the_last_message_by_phone_and_keywords(number, keywords):
    keywords = ",".join(keywords)
    payload = {"number": str(number), "keywords": keywords}
    r = requests.get(f'http://{phone_setting.host}:{phone_setting.port}/api/telephone/get_the_last_message_by_phone_and_keywords', params=payload)
    return r.json()["body"]


if __name__ == "__main__":
    print(get_random_phone())
    print(get_the_last_message_by_phone_and_keywords("17153787241", []))
